home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SUNRPC / XPRT.H < prev   
C/C++ Source or Header  |  1999-09-17  |  6KB  |  207 lines

  1. /*
  2.  *  linux/include/linux/sunrpc/clnt_xprt.h
  3.  *
  4.  *  Declarations for the RPC transport interface.
  5.  *
  6.  *  Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  7.  */
  8.  
  9. #ifndef _LINUX_SUNRPC_XPRT_H
  10. #define _LINUX_SUNRPC_XPRT_H
  11.  
  12. #include <linux/uio.h>
  13. #include <linux/socket.h>
  14. #include <linux/in.h>
  15. #include <linux/sunrpc/sched.h>
  16.  
  17. /*
  18.  * Maximum number of iov's we use.
  19.  */
  20. #define MAX_IOVEC    8
  21.  
  22. /*
  23.  * The transport code maintains an estimate on the maximum number of out-
  24.  * standing RPC requests, using a smoothed version of the congestion
  25.  * avoidance implemented in 44BSD. This is basically the Van Jacobson
  26.  * slow start algorithm: If a retransmit occurs, the congestion window is
  27.  * halved; otherwise, it is incremented by 1/cwnd when
  28.  *
  29.  *    -    a reply is received and
  30.  *    -    a full number of requests are outstanding and
  31.  *    -    the congestion window hasn't been updated recently.
  32.  *
  33.  * Upper procedures may check whether a request would block waiting for
  34.  * a free RPC slot by using the RPC_CONGESTED() macro.
  35.  *
  36.  * Note: on machines with low memory we should probably use a smaller
  37.  * MAXREQS value: At 32 outstanding reqs with 8 megs of RAM, fragment
  38.  * reassembly will frequently run out of memory.
  39.  * Come Linux 2.3, we'll handle fragments directly.
  40.  */
  41. #define RPC_MAXCONG        16
  42. #define RPC_MAXREQS        (RPC_MAXCONG + 1)
  43. #define RPC_CWNDSCALE        256
  44. #define RPC_MAXCWND        (RPC_MAXCONG * RPC_CWNDSCALE)
  45. #define RPC_INITCWND        RPC_CWNDSCALE
  46. #define RPCXPRT_CONGESTED(xprt) \
  47.     ((xprt)->cong >= ((xprt)->nocong? RPC_MAXCWND : (xprt)->cwnd))
  48.  
  49. /* Default timeout values */
  50. #define RPC_MAX_UDP_TIMEOUT    (6*HZ)
  51. #define RPC_MAX_TCP_TIMEOUT    (600*HZ)
  52.  
  53. /* RPC call and reply header size as number of 32bit words (verifier
  54.  * size computed separately)
  55.  */
  56. #define RPC_CALLHDRSIZE        6
  57. #define RPC_REPHDRSIZE        4
  58.  
  59. /*
  60.  * This describes a timeout strategy
  61.  */
  62. struct rpc_timeout {
  63.     unsigned long        to_current,        /* current timeout */
  64.                 to_initval,        /* initial timeout */
  65.                 to_maxval,        /* max timeout */
  66.                 to_increment,        /* if !exponential */
  67.                 to_resrvval;        /* reserve timeout */
  68.     short            to_retries;        /* max # of retries */
  69.     unsigned char        to_exponential;
  70. };
  71.  
  72. /*
  73.  * This is the RPC buffer
  74.  */
  75. struct rpc_iov {
  76.     struct iovec        io_vec[MAX_IOVEC];
  77.     unsigned int        io_nr;
  78.     unsigned int        io_len;
  79. };
  80.  
  81. /*
  82.  * This describes a complete RPC request
  83.  */
  84. struct rpc_rqst {
  85.     /*
  86.      * This is the user-visible part
  87.      */
  88.     struct rpc_xprt *    rq_xprt;        /* RPC client */
  89.     struct rpc_timeout    rq_timeout;        /* timeout parms */
  90.     struct rpc_iov        rq_snd_buf;        /* send buffer */
  91.     struct rpc_iov        rq_rcv_buf;        /* recv buffer */
  92.  
  93.     /*
  94.      * This is the private part
  95.      */
  96.     struct rpc_task *    rq_task;    /* RPC task data */
  97.     __u32            rq_xid;        /* request XID */
  98.     struct rpc_rqst *    rq_next;    /* free list */
  99.     unsigned char        rq_gotit;    /* reply received */
  100.     unsigned char        rq_damaged;    /* being received */
  101.  
  102.     /*
  103.      * For authentication (e.g. auth_des)
  104.      */
  105.     u32            rq_creddata[2];
  106.     
  107.     /*
  108.      * Partial send handling
  109.      */
  110.     
  111.     u32            rq_bytes_sent;    /* Bytes we have sent */
  112.  
  113. #ifdef RPC_PROFILE
  114.     unsigned long        rq_xtime;    /* when transmitted */
  115. #endif
  116. };
  117. #define rq_svec            rq_snd_buf.io_vec
  118. #define rq_snr            rq_snd_buf.io_nr
  119. #define rq_slen            rq_snd_buf.io_len
  120. #define rq_rvec            rq_rcv_buf.io_vec
  121. #define rq_rnr            rq_rcv_buf.io_nr
  122. #define rq_rlen            rq_rcv_buf.io_len
  123.  
  124. struct rpc_xprt {
  125.     struct rpc_xprt *    link;        /* list of all clients */
  126.     struct rpc_xprt *    rx_pending;    /* receive pending list */
  127.     
  128.     int             rx_pending_flag;/* are we on the pending list ? */
  129.  
  130.     struct file *        file;        /* VFS layer */
  131.     struct socket *        sock;        /* BSD socket layer */
  132.     struct sock *        inet;        /* INET layer */
  133.  
  134.     struct rpc_timeout    timeout;    /* timeout parms */
  135.     struct sockaddr_in    addr;        /* server address */
  136.     int            prot;        /* IP protocol */
  137.  
  138.     unsigned long        cong;        /* current congestion */
  139.     unsigned long        cwnd;        /* congestion window */
  140.     unsigned long        congtime;    /* hold cwnd until then */
  141.  
  142.     struct rpc_wait_queue    sending;    /* requests waiting to send */
  143.     struct rpc_wait_queue    pending;    /* requests in flight */
  144.     struct rpc_wait_queue    backlog;    /* waiting for slot */
  145.     struct rpc_wait_queue    reconn;        /* waiting for reconnect */
  146.     struct rpc_rqst *    free;        /* free slots */
  147.     struct rpc_rqst        slot[RPC_MAXREQS];
  148.     unsigned char        connected;    /* TCP: connected */
  149.     unsigned char        write_space;    /* TCP: can send */
  150.     unsigned int        shutdown   : 1,    /* being shut down */
  151.                 nocong       : 1,    /* no congestion control */
  152.                 stream     : 1,    /* TCP */
  153.                 tcp_more   : 1,    /* more record fragments */
  154.                 connecting : 1;    /* being reconnected */
  155.  
  156.     /*
  157.      * State of TCP reply receive stuff
  158.      */
  159.     union {                    /* record marker & XID */
  160.         u32        header[2];
  161.         u8         data[8];
  162.     }            tcp_recm;
  163.     struct rpc_rqst *    tcp_rqstp;
  164.     struct iovec        tcp_iovec[MAX_IOVEC];
  165.     u32            tcp_total;    /* overall record length */
  166.     u32            tcp_reclen;    /* fragment length */
  167.     u32            tcp_offset;    /* fragment offset */
  168.     u32            tcp_copied;    /* copied to request */
  169.  
  170.     /*
  171.      * TCP send stuff
  172.      */
  173.     struct rpc_iov        snd_buf;    /* send buffer */
  174.     struct rpc_task *    snd_task;    /* Task blocked in send */
  175.     u32            snd_sent;    /* Bytes we have sent */
  176.  
  177.  
  178.     void            (*old_data_ready)(struct sock *, int);
  179.     void            (*old_state_change)(struct sock *);
  180.     void            (*old_write_space)(struct sock *);
  181. };
  182. #define tcp_reclen        tcp_recm.header[0]
  183. #define tcp_xid            tcp_recm.header[1]
  184.  
  185. #ifdef __KERNEL__
  186.  
  187. struct rpc_xprt *    xprt_create(struct file *socket,
  188.                     struct sockaddr_in *addr,
  189.                     struct rpc_timeout *toparms);
  190. struct rpc_xprt *    xprt_create_proto(int proto, struct sockaddr_in *addr,
  191.                     struct rpc_timeout *toparms);
  192. int            xprt_destroy(struct rpc_xprt *);
  193. void            xprt_default_timeout(struct rpc_timeout *, int);
  194. void            xprt_set_timeout(struct rpc_timeout *, unsigned int,
  195.                     unsigned long);
  196.  
  197. int            xprt_reserve(struct rpc_task *);
  198. void            xprt_transmit(struct rpc_task *);
  199. void            xprt_receive(struct rpc_task *);
  200. int            xprt_adjust_timeout(struct rpc_timeout *);
  201. void            xprt_release(struct rpc_task *);
  202. void            xprt_reconnect(struct rpc_task *);
  203.  
  204. #endif /* __KERNEL__*/
  205.  
  206. #endif /* _LINUX_SUNRPC_XPRT_H */
  207.